package com.wushixin.springdemo.controller.utils;

import com.wushixin.springdemo.pojo.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(Exception.class)
    public Result doOtherException(Exception e) {
        e.printStackTrace();
        return new Result(false,"服务器发生异常");
    }

    @ExceptionHandler(value = CustomException.class)
    public Result CustomException(Exception e) {
        return new Result(false,e.getMessage());
    }
}
